package com.kkb.service;

import java.util.Date;
import java.util.List;
import java.util.Objects;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kkb.mapper.GameMapper;
import com.kkb.vo.GameVO;
import com.kkb.vo.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Game 服务层
 *
 * @author ztranscript 2021/9/2 20:28
 **/
@Service
public class GameService {
    @Autowired
    private GameMapper gameMapper;

    public PageInfo<GameVO> pageList(GameVO gameVO, PageParam pageParam) {
        // 开启分页
        PageHelper.startPage(pageParam.getPageNum(), pageParam.getPageSize());
        List<GameVO> pageList = gameMapper.pageList(gameVO);

        for (GameVO vo : pageList) {
            Integer status = vo.getStatus();
            if (Objects.equals(status, 0)) {
                vo.setStatusName("正常");
            } else if (Objects.equals(status, 1)) {
                vo.setStatusName("取消");
            } else if (Objects.equals(status, -1)) {
                vo.setStatusName("延迟");
            }
        }

        return new PageInfo<>(pageList);
    }
}
